package br.com.owl.cardapio;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.TextView;

import com.example.cardapio.R;

public class ListViewSubItemAdapter extends BaseAdapter{

	
	private static LayoutInflater layoutInflater;
	
	private Context context;
	
	private List<Cardapio> cardapios;
	
	
	public ListViewSubItemAdapter(LayoutInflater layoutInflater, Context context, List<Cardapio> cardapios) {
		
		this.layoutInflater = layoutInflater;
		
		this.context = context;
		
		this.cardapios = cardapios;
	}
	
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return cardapios.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return cardapios.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View view = null;
		
		
		if(convertView == null){
			
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			
			view = inflater.inflate(R.layout.produto_item_list_view, null);
		
		}else{
			
			view = (View) convertView;
		}
		
		
		TextView descricao = (TextView) view.findViewById(R.id.textViewItem);
		
		EditText quantidade = (EditText) view.findViewById(R.id.editText1);
		
		
		Cardapio cardapio = cardapios.get(position);
		
		descricao.setText(cardapio.getDescricao());
		
		
		
		return view;
	}

	
	
	
	
	
}
